package com.power.sifa.approve.model;


import com.plf.core.base.model.Ha_attachment;
import com.plf.core.common.annotations.FieldEnumText;
import com.plf.core.common.domain.BaseModel;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
import org.springframework.stereotype.Component;

import javax.persistence.*;
import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
*  委托代理人实体类
*/

@Entity
@ApiModel(value="委托代理人")
@Data
@Table(name="Apl_agent",schema="sfapprove")
@NoArgsConstructor
@EqualsAndHashCode(callSuper = false)
@Component
//@IdClass(Apl_agent.Apl_agentPK.class) 用于复合组件
public class Apl_agent extends BaseModel implements Serializable {

	private static final long serialVersionUID = 1L;

    @Id
    @Setter(AccessLevel.NONE)
    @ApiModelProperty(value = "applyid+nanoid")
    private String id;

    @ApiModelProperty(value = "代理人类型")
    private Integer type;

    @ApiModelProperty(value = "姓名")
    private String name;

    @ApiModelProperty(value = "证件类型")
    private Integer cardtype;

    @ApiModelProperty(value = "证件号")
    private String cardno;

    @ApiModelProperty(value = "性别")
    private Integer gender;

    @ApiModelProperty(value = "民族")
    private Integer nation;

    @ApiModelProperty(value = "送达地址（住址）")
    private String addr;

    @ApiModelProperty(value = "工作单位（律所名称）")
    private String unit;

    @ApiModelProperty(value = "电话")
    private String tel;

    @ApiModelProperty(value = "邮政编码")
    private String postcode;

    @ApiModelProperty(value = "applyid")
    private String applyid;

    @ApiModelProperty(value = "排序")
    private Integer sortnum = 0;

    @ApiModelProperty(value = "代理申请人/第三人")
    private String applicantname;

    @ApiModelProperty(value = "身份证明")
    private String filecard;

    @ApiModelProperty(value = "身份证明书")
    private String doccard;

    @ApiModelProperty(value = "委托书")
    private String fileentrust;

    @ApiModelProperty(value = "身份证明附件详情")
    @Transient
    private List<Ha_attachment> filecardList;

    @ApiModelProperty(value = "身份证明书详情")
    @Transient
    private List<Ha_attachment> doccardList;

    @ApiModelProperty(value = "委托书详情")
    @Transient
    private List<Ha_attachment> fileentrustList;


    /**
     *  代理人类型文本
     */
    @Transient
    @FieldEnumText(eum="Tp_agent", valuefield="type")
    private String type_text;

    /**
     *  证件类型文本
     */
    @Transient
    @FieldEnumText(eum="Tp_card", valuefield="cardtype")
    private String cardtype_text;

    /**
     *  性别文本
     */
    @Transient
    @FieldEnumText(eum="Tp_gender", valuefield="gender")
    private String gender_text;

    /**
     *  民族文本
     */
    @Transient
    @FieldEnumText(eum="Tp_nation", valuefield="nation")
    private String nation_text;


    public Map<String, Object> parseMap() {
        Map<String, Object> map=new HashMap<>();
        map.put("id", this.getId());
        map.put("type_text", this.type_text);
        map.put("type", this.getType());
        map.put("name", this.getName());
        map.put("cardtype_text", this.cardtype_text);
        map.put("cardtype", this.getCardtype());
        map.put("cardno", this.getCardno());
        map.put("gender_text", this.gender_text);
        map.put("gender", this.getGender());
        map.put("nation_text", this.nation_text);
        map.put("nation", this.getNation());
        map.put("addr", this.getAddr());
        map.put("unit", this.getUnit());
        map.put("tel", this.getTel());
        map.put("postcode", this.getPostcode());
        map.put("applyid", this.getApplyid());
        map.put("sortnum", this.getSortnum());
        map.put("applicantname", this.getApplicantname());
        return map;
    }

    public String getId() {
        return id;
    }

    public void setId(Serializable id) {
        this.id = (String) id;
    }

    public Serializable getPrimaryKey() {
        return id;
        // return new Apl_agentPK(id, id2); 用于复合主键，请手动创建内部静态类
    }

    public void setPrimaryKey(Serializable key) {
        this.id = (String)key;

        //Apl_agentPK pk = (Apl_agentPK) key; 用于复合主键
        //this.id = pk.getId();
        //this.id2 = pk.getId2();
    }

}
